package cn.doctorpda.conference.model;

import org.json.JSONObject;

import cn.doctorpda.conference.MyApplication;
import cn.doctorpda.conference.config.AppConfig;
import cn.doctorpda.conference.localstore.ClientInfo;
import cn.doctorpda.conference.okhttp.OkHttpUtils;
import cn.doctorpda.conference.okhttp.builder.OkHttpRequestBuilder;
import cn.doctorpda.conference.okhttp.callback.Callback;
import cn.doctorpda.conference.utils.AESUtil;
import cn.doctorpda.conference.utils.AppUtils;

/**
 * Created by huangjinlong on 2016/5/25.
 */
public class UpdataMomel implements IPostModel {

    @Override
    public void postNetWorkStringData(String url, Callback callback, String... parameter) {

        JSONObject object = new JSONObject();
        try {
            object.put("client_os ", "Android");
            object.put("cur_channel", "a681a1fi0r8t01ff");
        } catch (Exception e) {
            e.printStackTrace();
        }
        String data = AESUtil.encrypt(object.toString(), AppConfig.AES_KEY);


        OkHttpUtils.post()
                .url(url)
                .addParams("data", data)
                .addParams("app_key", AppConfig.AES_KEY)
                .addParams("client_os","Android")
                .addParams("client_id", ClientInfo.getClientId(MyApplication.getInstance()))
                .addParams("version_code", String.valueOf(AppUtils.getVersionCode(MyApplication.getInstance())))
                .build()
                .execute(callback);
    }
}
